package com.hue;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;

/*
    获取视频播放凭证
 */
public class VoeTest2 {
    public static void main(String[] args) throws ClientException {
        DefaultAcsClient client = initVodClient("LTAI5t77KMd1pNDZKer4Wuko", "EvDRXaj0Vc4JybCtrvxwEuVIp1ufuP");
        GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest();
        request.setVideoId("221e97a4eadc45229e9da3817535e800");
        GetVideoPlayAuthResponse response = client.getAcsResponse(request);
        String playAuth = response.getPlayAuth();
        System.out.println(playAuth);
        System.out.println(response.getVideoMeta());
    }

    public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
        String regionId = "cn-shanghai";  // 点播服务接入区域
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }
}
